<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增推送任务')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-itemInfo-add">
            <input type="hidden" id="infoId" name="infoId" th:value="${costomId}" />

            <div class="rows">
                <div class="col-sm-4" >

<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-3 control-label">描述：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <textarea rows="3"  cols="40" name="descInfo" placeholder="该任务的描述信息">asdf</textarea>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="form-group">
                        <label class="col-sm-3 control-label">价格：</label>
                        <div class="col-sm-8">
                            <input name="priceAmount" class="form-control" type="text" value="10">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">每日推送时间：</label>
                        <div class="col-sm-4 row" id="timeRange">
                            <input name="starttime" id="starttime" class="form-control" type="text" placeholder="开始时间" value="00:00:00" readonly>
                        </div>
                        <div class="col-sm-4">
                            <input name="endtime" id="endtime" class="form-control" type="text" placeholder="结束时间" value="23:59:59" readonly>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">年龄：</label>
                        <div class="col-sm-3">
                            <input name="minAge" class="form-control" type="text" placeholder="最小年龄" autocomplete="off" value="20">
                        </div>
                        <div class="col-sm-3">
                            <input name="maxAge" class="form-control" type="text" placeholder="最大年龄" autocomplete="off" value="60">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">允许推送的渠道信息：</label>
                        <div class="col-sm-8">
                            <textarea rows="3"  cols="40" name="inChannelArray" placeholder="允许推送的渠道信息"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">不允许推送的渠道信息：</label>
                        <div class="col-sm-8">
                            <textarea rows="3"  cols="40" name="outChannelArray" placeholder="不允许推送的渠道信息"></textarea>
                        </div>
                    </div>


<!--                    用户条件筛选-->
                    <div class="form-group" th:each="item:${multiInfoList}">
                        <label class="col-sm-3 control-label" th:text="${item.name} + ':'">:</label>
                        <div class="col-sm-8">
                            <label class="check-box" th:each="child:${item.childInfoList}">
                                <input type="checkbox" lay-skin="primary" th:name="${item.elemName}" th:value="${child.value}" th:text="${child.name}" >
                            </label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label"></label>
                        <div class="col-sm-8">
                            <button type="button"  onclick="submitHandler()" class="btn-primary btn">提交</button>
                        </div>
                    </div>

                </div>

                <div class="col-sm-4">
                    <input type="hidden" name="cityName" id="cityName" />
                    <div class="form-group">
                        <label class="col-sm-3 control-label">推送的省市：</label>
                        <div class="col-sm-8">
                            <div id="addressTrees" class="ztree ztree-border"></div>
                        </div>
                    </div>

                </div>

                <div class="col-sm-4">
                    <input type="hidden" name="outCityArray" id="outCityArray" />
                    <div class="form-group">
                        <label class="col-sm-3 control-label">不推送的省市：</label>
                        <div class="col-sm-8">
                            <div id="addressTrees1" class="ztree ztree-border"></div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <th:block th:include="include :: footer" />
    <th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var prefix = ctx + "special/itemInfo"
        $("#form-itemInfo-add").validate({
            focusCleanup: true
        });

        function submitHandler() {

            $("#cityName").val($.tree.getCheckedNodesByElemId("addressTrees"))
            $("#outCityArray").val($.tree.getCheckedNodesByElemId("addressTrees1"))

            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/add", $('#form-itemInfo-add').serialize());
            }
        }

        layui.use('laydate', function(){
            var laydate = layui.laydate;

            laydate.render({
                elem: '#timeRange',
                type: 'time',
                range: ['#starttime', '#endtime']
            });

        });

        /***
         * 地址树信息
         */
        $(function() {
            var url = ctx + "system/address/treeData";
            var options = {
                id: "addressTrees",
                url: url,
                check: { enable: true, chkboxType: { "Y": "", "N": "" } },
                expandLevel: 0
            };
            $.tree.init(options);
        });

        /***
         * 地址树信息
         */
        $(function() {
            var url = ctx + "system/address/treeData";
            var options = {
                id: "addressTrees1",
                url: url,
                check: { enable: true, chkboxType: { "Y": "", "N": "" } },
                expandLevel: 0
            };
            $.tree.init(options);
        });

    </script>
</body>
</html>